package com.example.springbootdisconf.config;

import com.baidu.disconf.client.common.annotations.DisconfItem;
import com.baidu.disconf.client.common.annotations.DisconfUpdateService;
import com.baidu.disconf.client.common.update.IDisconfUpdate;
import org.springframework.stereotype.Component;

@Component
//如果要监听配置项的修改可以像下面这样写，套路都是一样的
@DisconfUpdateService
public class KeyValueConfig implements IDisconfUpdate {
    private String aa;

    //@DisconfItem用于读取配置项的值，然后把它绑定到对应属性上
    @DisconfItem(key = "aa", associateField = "aa")
    public String getAa() {
        return aa;
    }

    public void setAa(String aa) {
        this.aa = aa;
    }

    @Override
    public void reload() throws Exception {
        System.out.println("然你看看aa的值：" + aa);
    }
}
